'use strict';
const db = uniCloud.database()
exports.main = async (event, context) => {
	try {
		let { data } = await db.collection('user').where({
			uname: event.uname,
		}).get()
		console.log(data)
		if(data.length == 0){
			return {
				code:400,
				msg:'无效的账号'
			}
		}
		if(data[0].upwd != event.upwd){
			return {
				code:400,
				msg:'密码错误'
			}
		}else{
			return {
				code:200,
				msg:'登陆成功'
			}
		}
	} catch (e) {
		//TODO handle the exception
	}
};
